package com.itbaizhan.cxpt.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itbaizhan.cxpt.entity.FileUploadRecord;
import com.itbaizhan.cxpt.service.FileUploadRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/file-records")
public class FileUploadRecordController {

    @Autowired
    private FileUploadRecordService fileUploadRecordService;

    @GetMapping("/list")
    public Page<FileUploadRecord> list(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size) {
        Page<FileUploadRecord> page = new Page<>(current, size);
        QueryWrapper<FileUploadRecord> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("upload_time");
        return fileUploadRecordService.page(page, queryWrapper);
    }
}